1. Field of the Invention
Apparatuses and methods consistent with the present invention relate to demand paging for an embedded system and, more particularly, to a demand paging apparatus and method for an embedded system that enable a demand paging technique to be simply and efficiently used when the demand paging technique is applied, either to a system in which an operating system supporting demand paging is used, or to a system in which an operating system is not used.
2. Related Art
The term “demand paging” refers to a technique in which, in an operating system using a virtual memory system, virtual memory is allocated to an auxiliary storage device such as a hard disk, and physical memory is mapped thereto at the request of a user, thereby enabling limited main memory to be used more efficiently. Although demand paging is used in general-purpose operating systems such as Linux and Windows, in response to increasing size of code and data required by application programs, such a function is not supported in most embedded systems due to its complicated mechanism. The reason for this is because each memory system itself is closely associated with the operation of a general-purpose operating system. That is, unless operating system supporting demand paging is used, it is difficult to implement demand paging in practice.
FIG. 1A is a diagram illustrating a related art demand paging apparatus in an operating system that supports demand paging, including physical memory 30 having a limited size, an auxiliary storage device 40 for generating virtual memory spaces for the demand paging, virtual address spaces 10 and 20 of respective processes for functioning as application programs, and an operating system 50 for managing the demand paging. When processes are generated, the operating system 50 generates virtual memory spaces for the respective processes in the auxiliary storage device 40. Thereafter, when the processes attempt to access the virtual memory spaces, the operating system 50 allocates appropriate spaces to the physical memory 30, reads the content of the virtual memory spaces from the auxiliary storage device 40, and then maps the content to the virtual address spaces 10 and 20 of the respective processes, thereby executing an application program.
In this case, the virtual address spaces 10 and 20 of the respective processes are classified into a kernel region and a user region. In the kernel region, a space having the same size as the space into which the code and static data of the operating system 50 are loaded is secured in the physical memory 30. The demand paging technique is applied to all of the remaining space. Therefore, all of the code and data are handled by the demand paging technique from the point of view of a user program.
FIG. 1B is a diagram illustrating a related art system that uses demand paging, including an address space 60 that is viewed and used by an application program 90, physical memory 70 existing in a system and having a limited size, an auxiliary storage device 80 for storing the application program, and the application program 90 stored in the auxiliary storage device 80, loaded into the physical memory 70, and then mapped to the address space 60.
In the system, the entire memory space is shared without being divided into regions corresponding to processes. Since the physical memory 70 may be mapped to the address space 60 unchanged, a program that has a size larger than that of the physical memory 70 of the system may not be executed. In general, the application program 90 stored in the auxiliary storage device 80 is loaded into the physical memory 70 through a boot loader and then executed.
To apply demand paging in the related art case of FIG. 1A, using a scheme of supporting the demand paging at the operating system level, there is a problem in that the operating system itself must be replaced with another operating system. Furthermore, since most operating systems for embedded systems do not support virtual address spaces for respective tasks, it is difficult to introduce the conventional demand paging scheme thereto. Alternatively, if an operating system supporting demand paging is used, it is difficult to predict the portion of an application program for which the processing will be delayed by demand paging and the moment at which the portion of an application program will be delayed by demand paging from the point of view of the application program. Therefore, there is a problem in that it is difficult to apply the system to applications that require real-time responses.
Furthermore, in the related art system of FIG. 1B, which does not use demand paging, there is a problem in that it is difficult to handle the gradually increasing size of code and data. Furthermore, when a program stored in the storage device is executed in the case where NAND flash memory, that is, nonvolatile memory that cannot be directly addressed or a hard disk, is employed in the system, there is a problem in that RAM having a size corresponding to the size of the program must be allocated.